package com.umpay.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * @ClassName: PropertyUtil  
 * @Description: 获取配置参数工具类  
 * @author zhangtao  
 * @date Jan 23, 2018
 */
@Configuration
@PropertySource(value = {"classpath:/param/global_params.properties",
		                 "classpath:/param/mapping_url.properties",
		                 "classpath:/param/diff.properties",
		                 "classpath:/param/mer_order_type.properties",
		                 "classpath:/config/asyn.properties"},
                ignoreResourceNotFound = true,encoding = "utf-8")
@Component
public class PropertyUtil {

	@Autowired
	private Environment env;
	
	@Bean
	public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(){
		return new PropertySourcesPlaceholderConfigurer();
	}
	
	public  String getProperty(String key){
		return StringUtils.trim(env.getProperty(key));
	}
}
